﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class GUI_Pages_BabySitterInfo : System.Web.UI.Page
{
    public static int bsID;
    public static int d;
    public static int accID;
    static string connStr = ConfigurationManager.ConnectionStrings["CSConn"].ToString();
    static SqlConnection conn = new SqlConnection(connStr);
    protected void Page_Load(object sender, EventArgs e)
    {

        ContentPlaceHolder mainContent = (ContentPlaceHolder)this.Master.FindControl("ContentPlaceHolder1");

        String s = Request.QueryString["bsID"];
        String dum = Request.QueryString["d"];
        bsID = Convert.ToInt32(s);
        d = Convert.ToInt32(dum);

        if (d == 1)
        {
            CheckBox7.Visible = false;
            CheckBox8.Visible = false;
            CheckBox9.Visible = false;
            Button3.Visible = false;
        }
        if (d == 2)
        {
            CheckBox6.Visible = false;
            Button1.Visible = false;
            Button2.Visible = false;
        }

        SqlCommand cmd1 = new SqlCommand("SELECT b.BSName, b.DoB, b.EMail, b.CellNo, b.PhoneNo, b.Gender, b.BS_Address, b.Area, b.PostalCode, c.CName, n.NName, b.Experience, b.Essay, b.Trained, a.Interviewed, b.PaidTraining, b.AccountID " +
            "FROM BabySitters AS b INNER JOIN Cities AS c ON b.CityID = c.CityID " +
            "INNER JOIN Nationalities AS n ON b.NationalityID = n.NationalityID " +
            "INNER JOIN Accounts AS a ON b.AccountID = a.AccountID " +
            "WHERE b.BSID = @bsid", conn);
        cmd1.CommandType = CommandType.Text;
        cmd1.Parameters.Add(new SqlParameter("@bsid", bsID));

        conn.Open();
        cmd1.ExecuteNonQuery();
        conn.Close();

        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd1);
        da.Fill(dt);
        string gen = dt.Rows[0].Field<String>(5);
        //if (dt.Rows[0].Field<bool>(13) == true)
        //{
        //    CheckBox7.Checked = true;
        //}
        //if (dt.Rows[0].Field<bool>(14) == true)
        //{
        //    CheckBox8.Checked = true;
        //}
        //if (dt.Rows[0].Field<bool>(15) == true)
        //{
        //    CheckBox9.Checked = true;
        //}
        if (gen == "F")
        {
            RadioButtonList1.SelectedValue = "Female";
        }
        else
        {
            RadioButtonList1.SelectedValue = "Male";
        }
        TextBox1.Text = dt.Rows[0].Field<String>(0);
        TextBox2.Text = dt.Rows[0].Field<DateTime>(1).ToString();
        TextBox3.Text = dt.Rows[0].Field<String>(3);
        TextBox4.Text = dt.Rows[0].Field<String>(4);
        TextBox6.Text = dt.Rows[0].Field<String>(10);
        TextBox7.Text = dt.Rows[0].Field<String>(2);
        TextBox8.Text = dt.Rows[0].Field<String>(6);
        TextBox9.Text = dt.Rows[0].Field<String>(7);
        TextBox10.Text = dt.Rows[0].Field<String>(8);
        TextBox11.Text = dt.Rows[0].Field<String>(9);
        TextBox18.Text = dt.Rows[0].Field<String>(11);
        TextBox22.Text = dt.Rows[0].Field<String>(12);
        accID = dt.Rows[0].Field<int>(16);

        SqlCommand cmd2 = new SqlCommand("SELECT bl.LanguageID " +
            "FROM BabySitters_Languages bl INNER JOIN Languages l ON bl.LanguageID = l.LanguageID " +
            "WHERE bl.BSID = @bsid", conn);
        cmd2.CommandType = CommandType.Text;
        cmd2.Parameters.Add(new SqlParameter("@bsid", bsID));

        conn.Open();
        cmd2.ExecuteNonQuery();
        conn.Close();

        DataTable dt2 = new DataTable();
        SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
        da2.Fill(dt2);

        for (int i = 0; i < dt2.Rows.Count; i++)
        {
            int langID = dt2.Rows[i].Field<int>(0);
            CheckboxList1.Items[langID - 1].Selected = true;
        }

        SqlCommand cmd3 = new SqlCommand("SELECT s.SUName, e.YearsCompleted, e.GraduationYear " +
            "FROM BabySitters b, BSEducationalBackground e, SchoolsUniversities s " +
            "WHERE b.BSID = e.BSID AND e.SUID = s.SUID AND b.BSID = @bsid", conn);
        cmd3.CommandType = CommandType.Text;
        cmd3.Parameters.Add(new SqlParameter("@bsid", bsID));

        conn.Open();
        cmd3.ExecuteNonQuery();
        conn.Close();

        DataTable dt3 = new DataTable();
        SqlDataAdapter da3 = new SqlDataAdapter(cmd3);
        da3.Fill(dt3);

        for (int i = 0; i < dt3.Rows.Count; i++)
        {
            TextBox school = (TextBox)mainContent.FindControl("School" + (i + 1));
            TextBox yrs = (TextBox)mainContent.FindControl("yrSchool" + (i + 1));
            TextBox grad = (TextBox)mainContent.FindControl("grad" + (i + 1));
            school.Text = dt3.Rows[i].Field<String>(0);
            yrs.Text = (dt3.Rows[i].Field<int>(1)).ToString();
            grad.Text = (dt3.Rows[i].Field<int>(2)).ToString();
        }

        SqlCommand cmd4 = new SqlCommand("SELECT s.EName, e.EDate, e.Duties " +
            "FROM BabySitters b, BSEmploymentBackground e, Employers s " +
            "WHERE b.BSID = e.BSID AND e.EmployerID = s.EmployerID AND b.BSID = @bsid", conn);
        cmd4.CommandType = CommandType.Text;
        cmd4.Parameters.Add(new SqlParameter("@bsid", bsID));

        conn.Open();
        cmd4.ExecuteNonQuery();
        conn.Close();

        DataTable dt4 = new DataTable();
        SqlDataAdapter da4 = new SqlDataAdapter(cmd4);
        da4.Fill(dt4);

        for (int i = 0; i < dt4.Rows.Count; i++)
        {
            TextBox employer = (TextBox)mainContent.FindControl("employer" + (i + 1));
            TextBox date = (TextBox)mainContent.FindControl("empDate" + (i + 1));
            TextBox duties = (TextBox)mainContent.FindControl("duties" + (i + 1));
            employer.Text = dt4.Rows[i].Field<String>(0);
            date.Text = dt4.Rows[0].Field<String>(1);
            duties.Text = dt4.Rows[0].Field<String>(2);
        }

        SqlCommand cmd5 = new SqlCommand("SELECT h.HSName " +
            "FROM BabySitters b, HobbiesSkills h, HSs_BSs hb " +
            "WHERE b.BSID = hb.BSID AND hb.HSID = h.HSID AND b.BSID = @bsid", conn);
        cmd5.CommandType = CommandType.Text;
        cmd5.Parameters.Add(new SqlParameter("@bsid", bsID));

        conn.Open();
        cmd5.ExecuteNonQuery();
        conn.Close();

        DataTable dt5 = new DataTable();
        SqlDataAdapter da5 = new SqlDataAdapter(cmd5);
        da5.Fill(dt5);

        for (int j = 0; j < dt5.Rows.Count; j++)
        {
            TextBox txtBox = (TextBox)mainContent.FindControl("hobby" + (j + 1));
            txtBox.Text = dt5.Rows[j].Field<String>(0);

        }


        SqlCommand cmd6 = new SqlCommand("SELECT b.Allergies, b.Petconcern, wc.clubs, wc.cinemas, wc.otherEvents, wc.withparentsathome, wc.withparentsatclub, " +
            "wc.withmaidathome, wc.withmaidatclub, wc.aloneathome, wc.aloneatclub, wc.daycaretwosix, wc.daycaresixtwelve, wc.nightcare, " +
            "wc.workoffsched, wc.hoursaweek, wc.hoursaday " +
            "FROM BabySitters b, BSWorkConditions wc " +
            "WHERE b.BSID = wc.BSID AND b.BSID = @bsid", conn);
        cmd6.CommandType = CommandType.Text;
        cmd6.Parameters.Add(new SqlParameter("@bsid", bsID));
        conn.Open();
        cmd6.ExecuteNonQuery();
        conn.Close();

        DataTable dt6 = new DataTable();
        SqlDataAdapter da6 = new SqlDataAdapter(cmd6);
        da6.Fill(dt6);

        if (dt6.Rows[0].Field<String>(0) == "" || dt6.Rows[0].Field<String>(0) == null)
            TextBox23.Text = "None";
        else
            TextBox23.Text = dt6.Rows[0].Field<String>(0);
        if (dt6.Rows[0].Field<String>(1) == "" || dt6.Rows[0].Field<String>(1) == null)
            TextBox24.Text = "None";
        else
            TextBox24.Text = dt6.Rows[0].Field<String>(1);
        RadioButtonList2.SelectedValue = (dt6.Rows[0].Field<bool>(2)).ToString();
        RadioButtonList3.SelectedValue = (dt6.Rows[0].Field<bool>(3)).ToString();
        RadioButtonList4.SelectedValue = (dt6.Rows[0].Field<bool>(4)).ToString();
        if ((dt6.Rows[0].Field<bool>(11)).ToString() == "True")
        {
            CheckBox1.Checked = true;
            CheckBox2.Checked = true;
        }
        if ((dt6.Rows[0].Field<bool>(12)).ToString() == "True")
        {
            CheckBox1.Checked = true;
            CheckBox3.Checked = true;
        }
        if ((dt6.Rows[0].Field<bool>(13)).ToString() == "True")
        {
            CheckBox4.Checked = true;
        }
        if ((dt6.Rows[0].Field<bool>(14)).ToString() == "True")
        {
            CheckBox5.Checked = true;
        }

        for (int k = 5; k < 11; k++)
        {
            String wc = (dt6.Rows[0].Field<bool>(k)).ToString();
            if (wc == "True")
            {
                if (k == 5)
                    bWorkConditionCheck.Items.FindByValue("1").Selected = true;
                if (k == 6)
                    bWorkConditionCheck.Items.FindByValue("4").Selected = true;
                if (k == 7)
                    bWorkConditionCheck.Items.FindByValue("2").Selected = true;
                if (k == 8)
                    bWorkConditionCheck.Items.FindByValue("5").Selected = true;
                if (k == 9)
                    bWorkConditionCheck.Items.FindByValue("3").Selected = true;
                if (k == 10)
                    bWorkConditionCheck.Items.FindByValue("6").Selected = true;
            }
        }
        TextBox25.Text = (dt6.Rows[0].Field<int>(15)).ToString();
        TextBox26.Text = (dt6.Rows[0].Field<int>(16)).ToString();

        SqlCommand cmd7 = new SqlCommand("SELECT e.ECName, e.MobileNo, e.PhoneNo, ea.Relationship " +
            "FROM EmergencyContacts e, EmergencyContacts_Accounts ea, BabySitters b " +
            "WHERE b.BSID = @bsid AND b.AccountID = ea.AccountID AND ea.ECID = e.ECID", conn);
        cmd7.CommandType = CommandType.Text;
        cmd7.Parameters.Add(new SqlParameter("@bsid", bsID));
        conn.Open();
        cmd7.ExecuteNonQuery();
        conn.Close();

        DataTable dt7 = new DataTable();
        SqlDataAdapter da7 = new SqlDataAdapter(cmd7);
        da7.Fill(dt7);

        for (int i = 0; i < dt7.Rows.Count; i++)
        {
            TextBox ec = (TextBox)mainContent.FindControl("ec" + (i + 1));
            TextBox mob = (TextBox)mainContent.FindControl("ecMob" + (i + 1));
            TextBox home = (TextBox)mainContent.FindControl("ecHome" + (i + 1));
            TextBox relationship = (TextBox)mainContent.FindControl("ecRelationship" + (i + 1));
            ec.Text = dt7.Rows[i].Field<String>(0);
            mob.Text = dt7.Rows[i].Field<String>(1);
            home.Text = dt7.Rows[i].Field<String>(2);
            relationship.Text = dt7.Rows[i].Field<String>(3);
        }
        
        SqlCommand cmd8 = new SqlCommand("SELECT bs.S_Day, d.DHID " +
            "FROM BSSchedule bs, DH_BSS d " +
            "WHERE bs.BSID = @bsid AND bs.BSSID = d.BSSID ", conn);
        cmd8.CommandType = CommandType.Text;
        cmd8.Parameters.Add(new SqlParameter("@bsid", bsID));
        conn.Open();
        cmd8.ExecuteNonQuery();
        conn.Close();

        DataTable dt8 = new DataTable();
        SqlDataAdapter da8 = new SqlDataAdapter(cmd8);
        da8.Fill(dt8);

        for (int i = 0; i < dt8.Rows.Count; i++)
        {
            String day = dt8.Rows[i].Field<String>(0);
            string hour = (dt8.Rows[i].Field<int>(1)).ToString();
            if (dt8.Rows[i].Field<int>(1) < 10 && dt8.Rows[i].Field<int>(1) > 0)
            {
                hour = "0" + (dt8.Rows[i].Field<int>(1)).ToString();
            }
            if (day == "Sunday")
            {
                bSchedule.Items.FindByValue(hour + ",1").Selected = true;
            }
            if (day == "Monday")
            {
                bSchedule.Items.FindByValue(hour + ",2").Selected = true;
            }
            if (day == "Tuesday")
            {
                bSchedule.Items.FindByValue(hour + ",3").Selected = true;
            }
            if (day == "Wednesday")
            {
                bSchedule.Items.FindByValue(hour + ",4").Selected = true;
            }
            if (day == "Thursday")
            {
                bSchedule.Items.FindByValue(hour + ",5").Selected = true;
            }
            if (day == "Friday")
            {
                bSchedule.Items.FindByValue(hour + ",6").Selected = true;
            }
            if (day == "Saturday")
            {
                bSchedule.Items.FindByValue(hour + ",7").Selected = true;
            }
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        String s = Request.QueryString["bsID"];
        int bsID = Convert.ToInt32(s);

        SqlCommand cmd9 = new SqlCommand("UPDATE Accounts SET Approved = 'False' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsID)", conn);
        cmd9.CommandType = CommandType.Text;
        cmd9.Parameters.Add(new SqlParameter("@bsid", bsID));
        conn.Open();
        cmd9.ExecuteNonQuery();
        conn.Close();

        //Response.Redirect("http://localhost:60070/CSWebSite_v1.0/GUI/Pages/Admin.aspx");
        Response.Redirect("http://www.cairositters.com/GUI/Pages/Admin.aspx");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String query = "UPDATE Accounts SET Approved = 'True' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsid)";
        if (CheckBox6.Checked == true)
        {
            query = "UPDATE Accounts SET Approved = 'True' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsid) " +
                "UPDATE Accounts SET Interviewed = 'True' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsid)";
        }

        String s = Request.QueryString["bsID"];
        int bsID = Convert.ToInt32(s);

        SqlCommand cmd10 = new SqlCommand(query, conn);
        cmd10.CommandType = CommandType.Text;
        cmd10.Parameters.Add(new SqlParameter("@bsid", bsID));
        conn.Open();
        cmd10.ExecuteNonQuery();
        conn.Close();

        // Response.Redirect("http://localhost:60070/CSWebSite_v1.0/GUI/Pages/Admin.aspx");
        Response.Redirect("http://www.cairositters.com/GUI/Pages/Admin.aspx");
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        String query = "UPDATE Accounts SET Interviewed = 'False' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsid) " +
                "UPDATE BabySitters SET Trained = 'False' WHERE  BSID = @bsid " +
                "UPDATE BabySitters SET PaidTraining = 'False' WHERE  BSID = @bsid";
        if (CheckBox7.Checked == true && CheckBox8.Checked == true && CheckBox9.Checked == true)
        {
            query = "UPDATE Accounts SET Interviewed = 'True' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsid) " +
                "UPDATE BabySitters SET Trained = 'True' WHERE  BSID = @bsid " +
                "UPDATE BabySitters SET PaidTraining = 'True' WHERE  BSID = @bsid";
        }
        if (CheckBox7.Checked == true && CheckBox8.Checked == true && CheckBox9.Checked == false)
        {
            query = "UPDATE Accounts SET Interviewed = 'True' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsid) " +
                "UPDATE BabySitters SET Trained = 'True' WHERE  BSID = @bsid " +
                "UPDATE BabySitters SET PaidTraining = 'False' WHERE  BSID = @bsid";
        }
        if (CheckBox7.Checked == false && CheckBox8.Checked == true && CheckBox9.Checked == true)
        {
            query = "UPDATE Accounts SET Interviewed = 'True' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsid) " +
                "UPDATE BabySitters SET Trained = 'False' WHERE  BSID = @bsid " +
                "UPDATE BabySitters SET PaidTraining = 'True' WHERE  BSID = @bsid";
        }
        if (CheckBox7.Checked == false && CheckBox8.Checked == true && CheckBox9.Checked == false)
        {
            query = "UPDATE Accounts SET Interviewed = 'True' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsid) " +
                "UPDATE BabySitters SET Trained = 'False' WHERE  BSID = @bsid " +
                "UPDATE BabySitters SET PaidTraining = 'False' WHERE  BSID = @bsid";
        }
        if (CheckBox7.Checked == true && CheckBox8.Checked == false && CheckBox9.Checked == false)
        {
            query = "UPDATE Accounts SET Interviewed = 'False' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsid) " +
                "UPDATE BabySitters SET Trained = 'True' WHERE  BSID = @bsid " +
                "UPDATE BabySitters SET PaidTraining = 'False' WHERE  BSID = @bsid";
        }
        if (CheckBox7.Checked == false && CheckBox8.Checked == false && CheckBox9.Checked == true)
        {
            query = "UPDATE Accounts SET Interviewed = 'False' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsid) " +
                "UPDATE BabySitters SET Trained = 'False' WHERE  BSID = @bsid " +
                "UPDATE BabySitters SET PaidTraining = 'True' WHERE  BSID = @bsid";
        }
        if (CheckBox7.Checked == true && CheckBox8.Checked == false && CheckBox9.Checked == true)
        {
            query = "UPDATE Accounts SET Interviewed = 'False' WHERE AccountID = (SELECT AccountID FROM BabySitters WHERE BSID = @bsid) " +
                "UPDATE BabySitters SET Trained = 'True' WHERE  BSID = @bsid " +
                "UPDATE BabySitters SET PaidTraining = 'True' WHERE  BSID = @bsid";
        }

        String s = Request.QueryString["bsID"];
        int bsID = Convert.ToInt32(s);

        SqlCommand cmd11 = new SqlCommand(query, conn);
        cmd11.CommandType = CommandType.Text;
        cmd11.Parameters.Add(new SqlParameter("@bsid", bsID));
        conn.Open();
        cmd11.ExecuteNonQuery();
        conn.Close();

        //Response.Redirect("http://localhost:60070/CSWebSite_v1.0/GUI/Pages/Admin.aspx");
        Response.Redirect("http://www.cairositters.com/GUI/Pages/Admin.aspx");
    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        TextBox1.Enabled = true;
        TextBox2.Enabled = true;
        TextBox3.Enabled = true;
        TextBox4.Enabled = true;
        TextBox6.Enabled = true;
        TextBox7.Enabled = true;
        TextBox8.Enabled = true;
        TextBox9.Enabled = true;
        TextBox10.Enabled = true;
        TextBox11.Enabled = true;
        TextBox18.Enabled = true;
        TextBox22.Enabled = true;
        TextBox23.Enabled = true;
        TextBox24.Enabled = true;
        School1.Enabled = true;
        School2.Enabled = true;
        School3.Enabled = true;
        School4.Enabled = true;
        yrSchool1.Enabled = true;
        yrSchool2.Enabled = true;
        yrSchool3.Enabled = true;
        yrSchool4.Enabled = true;
        grad1.Enabled = true;
        grad2.Enabled = true;
        grad3.Enabled = true;
        grad4.Enabled = true;
        employer1.Enabled = true;
        employer2.Enabled = true;
        empDate1.Enabled = true;
        empDate2.Enabled = true;
        duties1.Enabled = true;
        duties2.Enabled = true;
        hobby1.Enabled = true;
        hobby2.Enabled = true;
        hobby3.Enabled = true;
        hobby4.Enabled = true;
        hobby5.Enabled = true;
        hobby6.Enabled = true;
        ec1.Enabled = true;
        ecHome1.Enabled = true;
        ecMob1.Enabled = true;
        ecRelationship1.Enabled = true;
        ec2.Enabled = true;
        ecHome2.Enabled = true;
        ecMob2.Enabled = true;
        ecRelationship2.Enabled = true;
        RadioButtonList1.Enabled = true;
        RadioButtonList2.Enabled = true;
        RadioButtonList3.Enabled = true;
        RadioButtonList4.Enabled = true;
        CheckBox1.Enabled = true;
        CheckBox2.Enabled = true;
        CheckBox3.Enabled = true;
        CheckBox4.Enabled = true;
        CheckBox5.Enabled = true;
        CheckBox6.Enabled = true;
        CheckBox7.Enabled = true;
        CheckBox8.Enabled = true;
        CheckBox9.Enabled = true;
        CheckboxList1.Enabled = true;
        bSchedule.Enabled = true;
        bWorkConditionCheck.Enabled = true;
        LinkButton1.Visible = false;
        Button4.Visible = true;
        CheckBox7.Visible = false;
        CheckBox8.Visible = false;
        CheckBox9.Visible = false;
        Button3.Visible = false;
        CheckBox6.Visible = false;
        Button1.Visible = false;
        Button2.Visible = false;
        TextBox25.Enabled = true;
        TextBox26.Enabled = true;
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        string updBabysitter = "UPDATE BabySitters SET BSName = @bsname, EMail = @email, CellNo = @cellno, PhoneNo = @phoneno, " +
            "BS_Address = @bsaddress, Area = @area, PostalCode = @postalcode, CityID = @cityID, Experience = @experience, Essay = @essay, " +
            "Allergies = @allergies, Petconcern = @petconcern WHERE BSID = @bsid ";
        string updWorkCond = "UPDATE BSWorkConditions SET clubs = @clubs, cinemas = @cinemas, otherEvents = @other, withparentsathome = @parentsathome, " +
            "withparentsatclub = @parentsatclub, withmaidathome = @maidathome, withmaidatclub = @maidatclub, " +
            "aloneathome = @aloneathome, aloneatclub = @aloneatclub, daycaretwosix = @twosix, daycaresixtwelve = @sixtwelve, " +
            "nightcare = @nightcare, workoffsched = @notify, hoursaweek = @hrsweek, hoursaday = @hrsday WHERE BSID = @bsid ";
        
        SqlCommand cmd2 = new SqlCommand(updBabysitter + updWorkCond, conn);
        cmd2.CommandType = CommandType.Text;

        cmd2.Parameters.Add(new SqlParameter("@bsID", bsID));
        cmd2.Parameters.Add(new SqlParameter("@bsname", TextBox1.Text));
        cmd2.Parameters.Add(new SqlParameter("@cellno", TextBox3.Text));
        cmd2.Parameters.Add(new SqlParameter("@phoneno", TextBox4.Text));
        cmd2.Parameters.Add(new SqlParameter("@email", TextBox7.Text));
        cmd2.Parameters.Add(new SqlParameter("@bsaddress", TextBox8.Text));
        cmd2.Parameters.Add(new SqlParameter("@area", TextBox9.Text));
        cmd2.Parameters.Add(new SqlParameter("@cityID", 1));
        cmd2.Parameters.Add(new SqlParameter("@postalcode", TextBox10.Text));
        cmd2.Parameters.Add(new SqlParameter("@experience", TextBox18.Text));
        cmd2.Parameters.Add(new SqlParameter("@essay", TextBox22.Text));
        cmd2.Parameters.Add(new SqlParameter("@allergies", TextBox23.Text));
        cmd2.Parameters.Add(new SqlParameter("@petconcern", TextBox24.Text));
        cmd2.Parameters.Add(new SqlParameter("@clubs", Methods.conditionsRadio(RadioButtonList2)));
        cmd2.Parameters.Add(new SqlParameter("@cinemas", Methods.conditionsRadio(RadioButtonList3)));
        cmd2.Parameters.Add(new SqlParameter("@other", Methods.conditionsRadio(RadioButtonList4)));
        cmd2.Parameters.Add(new SqlParameter("@parentsathome", Methods.conditionsCheckitem(bWorkConditionCheck, 0)));
        cmd2.Parameters.Add(new SqlParameter("@parentsatclub", Methods.conditionsCheckitem(bWorkConditionCheck, 3)));
        cmd2.Parameters.Add(new SqlParameter("@maidathome", Methods.conditionsCheckitem(bWorkConditionCheck, 1)));
        cmd2.Parameters.Add(new SqlParameter("@maidatclub", Methods.conditionsCheckitem(bWorkConditionCheck, 4)));
        cmd2.Parameters.Add(new SqlParameter("@aloneathome", Methods.conditionsCheckitem(bWorkConditionCheck, 2)));
        cmd2.Parameters.Add(new SqlParameter("@aloneatclub", Methods.conditionsCheckitem(bWorkConditionCheck, 5)));
        cmd2.Parameters.Add(new SqlParameter("@twosix", Methods.conditionsCheck(CheckBox2)));
        cmd2.Parameters.Add(new SqlParameter("@sixtwelve", Methods.conditionsCheck(CheckBox3)));
        cmd2.Parameters.Add(new SqlParameter("@nightcare", Methods.conditionsCheck(CheckBox4)));
        cmd2.Parameters.Add(new SqlParameter("@notify", Methods.conditionsCheck(CheckBox5)));
        cmd2.Parameters.Add(new SqlParameter("@hrsweek", int.Parse(TextBox25.Text)));
        cmd2.Parameters.Add(new SqlParameter("@hrsday", int.Parse(TextBox26.Text)));

        conn.Open();
        cmd2.ExecuteNonQuery();
        conn.Close();

        Methods.deleteExisting(bsID);

        for (int k = 0; k < CheckboxList1.Items.Count; k++)
        {
            if (CheckboxList1.Items[k].Selected)
            {
                int x = int.Parse(CheckboxList1.Items[k].Value);
                SqlCommand cmd3 = new SqlCommand("INSERT INTO BabySitters_Languages(BSID, LanguageID) VALUES (@bsID, @languageID)", conn);
                cmd3.CommandType = CommandType.Text;

                cmd3.Parameters.Add(new SqlParameter("@bsID", bsID));
                cmd3.Parameters.Add(new SqlParameter("@languageID", x));

                conn.Open();
                cmd3.ExecuteNonQuery();
                conn.Close();
            }
        }

        if (School1.Text != "" && yrSchool1.Text != "" && grad1.Text != "")
        {
            Methods.AddEducation(bsID, School1, yrSchool1, grad1, e);
        }
        if (School2.Text != "" && yrSchool2.Text != "" && grad2.Text != "")
        {
            Methods.AddEducation(bsID, School2, yrSchool2, grad2, e);
        }
        if (School3.Text != "" && yrSchool3.Text != "" && grad3.Text != "")
        {
            Methods.AddEducation(bsID, School3, yrSchool3, grad3, e);
        }
        if (School4.Text != "" && yrSchool4.Text != "" && grad4.Text != "")
        {
            Methods.AddEducation(bsID, School4, yrSchool4, grad4, e);
        }

        if (employer1.Text != "" && duties1.Text !="" && empDate1.Text != "")
        {
            Methods.AddEmployment(bsID, employer1, empDate1, duties1, e);
        }
        if (employer2.Text != "" && duties2.Text != "" && empDate2.Text != "")
        {
            Methods.AddEmployment(bsID, employer2, empDate2, duties2, e);
        }

        if (hobby1.Text != "")
        {
            Methods.AddHobby(bsID, hobby1);
        }
        if (hobby2.Text != "")
        {
            Methods.AddHobby(bsID, hobby2);
        }
        if (hobby3.Text != "")
        {
            Methods.AddHobby(bsID, hobby3);
        }
        if (hobby4.Text != "")
        {
            Methods.AddHobby(bsID, hobby4);
        }
        if (hobby5.Text != "")
        {
            Methods.AddHobby(bsID, hobby5);
        }
        if (hobby6.Text != "")
        {
            Methods.AddHobby(bsID, hobby6);
        }
        if (ec1.Text != "" && ecMob1.Text != "" && ecHome1.Text != "" && ecRelationship1.Text != "")
        {
            Methods.AddEmergencyContact(accID, ec1, ecMob1, ecHome1, ecRelationship1);
        }
        if (ec2.Text != "" && ecMob2.Text != "" && ecHome2.Text != "" && ecRelationship2.Text != "")
        {
            Methods.AddEmergencyContact(accID, ec2, ecMob2, ecHome2, ecRelationship2);
        }

        for (int i = 0; i < bSchedule.Items.Count; i++)
        {
            if (bSchedule.Items[i].Selected)
            {
                string[] a = bSchedule.Items[i].Value.Split(',');
                int dhID = int.Parse(a[0]);
                if (a[1] == "1")
                {
                    Methods.AddScheduleSlot(bsID, dhID, "Sunday");
                }
                if (a[1] == "2")
                {
                    Methods.AddScheduleSlot(bsID, dhID, "Monday");
                }
                if (a[1] == "3")
                {
                    Methods.AddScheduleSlot(bsID, dhID, "Tuesday");
                }
                if (a[1] == "4")
                {
                    Methods.AddScheduleSlot(bsID, dhID, "Wednesday");
                }
                if (a[1] == "5")
                {
                    Methods.AddScheduleSlot(bsID, dhID, "Thursday");
                }
                if (a[1] == "6")
                {
                    Methods.AddScheduleSlot(bsID, dhID, "Friday");
                }
                if (a[1] == "7")
                {
                    Methods.AddScheduleSlot(bsID, dhID, "Saturday");
                }
            }
        }

        //Response.Redirect("http://www.cairositters.com/GUI/Pages/BabysitterInfo.aspx?bsID=" + bsID + "&d=" + d);
        Response.Redirect("http://localhost:60070/CSWebSite_v1.0/GUI/Pages/BabysitterInfo.aspx?bsID=" + bsID + "&d=" + d);
    }
}